package com.itheima.service.impl;
import com.itheima.mapper.ReportMapper;
import com.itheima.pojo.ClazzOption;
import com.itheima.pojo.JobOption;
import com.itheima.service.DeptService;
import com.itheima.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Service
public class ReportServiceImpl implements ReportService {
    @Autowired
    private ReportMapper reportMapper;

    /**
     * 员工性别分布数据
     * @return
     */
    @Override
    public List<Map> empGenderData() {
        return reportMapper.empGenderData();
    }

    /**
     * 员工职位分布数据
     * @return
     */
    @Override
    public JobOption empJobData() {
        List<Map> mapList =reportMapper.empJobData();

        List<Object> jobList = mapList.stream().map(map -> {
            return map.get("pos");
        }).collect(Collectors.toList());

        List<Object> dataList = mapList.stream().map(map -> {
            return map.get("posCount");
        }).collect(Collectors.toList());
        return new JobOption(jobList,dataList);
    }

    /**
     * 学员学历统计
     * @return
     */
    @Override
    public List<Map> studentDegreeData() {
        return reportMapper.studentDegreeData();
    }

    /**
     * 班级数量统计
     * @return
     */
    @Override
    public ClazzOption studentCountData() {
        List<Map> mapList = reportMapper.studentCountData();

        List<Object> clazzList = mapList.stream().map(map -> {
            return map.get("pos");
        }).collect(Collectors.toList());

        List<Object> dataList = mapList.stream().map(map -> {
            return map.get("posCount");
        }).collect(Collectors.toList());
        return new ClazzOption(clazzList,dataList);
    }
}
